<template>
  <div class="item" @click="playsong">
    <div class="msg">
      <div class="name">
        {{ item.name }}
        <span v-if="item.alia && item.alia.length != 0"
          >({{ item.alia[0] }})</span
        >
      </div>
      <div class="artists">
        <span v-for="(art, index) in item.ar" :key="art.id">
          {{ art.name }}
          <span v-if="index != item.ar.length - 1" style="padding: 0 5px"
            >/</span
          >
          <span v-if="index == item.ar.length - 1" style="padding: 0 5px"
            >-</span
          >
        </span>
        <span>{{ item.name }}</span>
      </div>
    </div>
    <i class="iconfont icon-icon-13 play"></i>
  </div>
</template>

<script>
import { mapMutations } from "vuex";
import { getSong } from "../api/recommend";
export default {
  name: "newsongItem",
  data() {
    return {
      item: {},
    };
  },
  props: {
    id: {
      type: Number,
    },
  },
  methods: {
    ...mapMutations(["xplaysong"]),
    ...mapMutations(["xsavenowList"]),
    playsong() {
      this.xplaysong(this.item);
    },
  },
  created() {
    getSong(this.id).then((res) => {
      this.item = res.songs[0];
      // this.xsavenowList(this.item);
      // console.log(nowList);
    });
  },
};
</script>

<style lang="scss" scoped>
.item {
  padding: 10px 0;
  box-sizing: border-box;
  height: 70px;
  position: relative;
  border-bottom: 1px solid #ccc;
  margin-left: 10px;
  display: flex;
  justify-content: space-between;
  .msg {
    flex: 0 0 300px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    .name {
      display: flex;
      align-items: center;
      font-size: 16px;
      padding-bottom: 10px;
 
      span {
        display: inline-block;
        color: #aaa;
        

        padding-left: 5px;
      }
    }
  }

  .artists {
    color: #aaa;
    font-size: 12px;
    width: 90%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .play {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translate(-10px, -50%);
  }
  > i {
    font-size: 30px;
  }
}
</style>
